<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./OL_SDK/include-openlayers-local.js"></script>
    <script src="./libs/gaode.js"></script>
</head>

<body>
    <div id="map">
    </div>
    <script>
        var map = new ol.Map({
            target: "map",
            layers: [gaode],
            view: new ol.View({
                projection: 'EPSG:4326',
                center: [114.30, 30.50],
                zoom: 4
            })
        })
        /* Feature,Source,Layer,Map */
        /* 1、Feature */
        const line = new ol.Feature({
            geometry: new ol.geom.LineString(
                [
                    [114.30, 30.50],
                    [116, 30.50]
                ]
            )
        })
        const style = new ol.style.Style({
            //边线颜色（边框 （描边））
            /* 线要素 只需要设置stroke属性 */
            stroke: new ol.style.Stroke({
                color: '#ffcc33',
                width: 5
            })
        })
        // line.setStyle(style)
        /* 2、source 矢量数据源*/
        const source = new ol.source.Vector({
            features: [line]
        })
        // × source.setStyle(style)// source.setStyle is not a function
        /* 3、layer  矢量图层 */
        const layer = new ol.layer.Vector({
            source
        })
        layer.setStyle(style)
        /* 4、map */
        map.addLayer(layer)
    </script>
</body>

</html>